package cn.exrick.xboot.common.qywxCode;


import cn.exrick.xboot.common.utils.ResultUtil;
import cn.exrick.xboot.common.utils.SpringContextUtil;
import cn.exrick.xboot.modules.base.dao.mapper.UserRoleMapper;
import cn.exrick.xboot.modules.base.entity.User;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;

public class IsWxUser {
    @Autowired
    UserRoleMapper userRoleMapper;
    @Autowired
    ResultUtil resultUtil;

    public int isWx(String user) {
        Map map = new HashMap();
        userRoleMapper = (UserRoleMapper) SpringContextUtil.getBean("userRoleMapper");
        IsPhoneNum isPhoneNum = new IsPhoneNum();
        if (isPhoneNum.isMobile(user)) {
            map.put("mobile", user);
        } else {
            map.put("username", user);
        }

        Integer wxStatus = userRoleMapper.IsWxUser(map);
        if (wxStatus == null) {
                   return 1;
        } else if (wxStatus == -1) {
            return 2;
        } else {
            return 3;
        }


    }
}
